import requests
import pymysql
host='sh-cdb-lksdvfsw.sql.tencentcdb.com'
port=63013
user='root'
password='zhang990113'
db='test'
tabel='hb'
def inserthb(time,url,type,fromUsername,lucky):
	connection = pymysql.connect(host=host, port=port, user=user, password=password, db=db, charset='utf8mb4', cursorclass=pymysql.cursors.DictCursor)
	cursor = connection.cursor()
	sql="INSERT INTO `hb` (`r_id`, `r_url`, `r_money`, `r_type`,`r_user`,`r_lucky`) VALUES ('%s', '%s', '0', '%s','%s','%s')"%(time,url,type,fromUsername,lucky)
	try:    
		cursor.execute(sql)    
		connection.commit()  
	except:  
		connection.rollback()  
		connection.close()
		return False 
	connection.close()
	return True
if __name__=='__main__':
	print(inserthb(153,"23","1",'fromUsername',"12"))